<!DOCTYPE HTML>
<html>
<head>
	<meta charset="utf-8">
	<meta name="renderer" content="webkit|ie-comp|ie-stand">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
	<meta http-equiv="Cache-Control" content="no-siteapp" />
	<!--[if lt IE 9]>
	<script type="text/javascript" src="#(ctx_path)/lib/html5shiv.js"></script>
	<script type="text/javascript" src="#(ctx_path)/lib/respond.min.js"></script>
	<![endif]-->
	<link rel="stylesheet" type="text/css" href="#(ctx_path)/static/h-ui/css/H-ui.min.css" />
	<link rel="stylesheet" type="text/css" href="#(ctx_path)/static/h-ui.admin/css/H-ui.admin.css" />
	<link rel="stylesheet" type="text/css" href="#(ctx_path)/lib/Hui-iconfont/1.0.8/iconfont.css" />
	<link rel="stylesheet" type="text/css" href="#(ctx_path)/static/h-ui.admin/skin/default/skin.css" id="skin" />
	<link rel="stylesheet" type="text/css" href="#(ctx_path)/static/h-ui.admin/css/style.css" />
	<link rel="stylesheet" href="#(ctx_path)/lib/zTree/v3/css/zTreeStyle/zTreeStyle.css" type="text/css">
	<!--[if IE 6]>
	<script type="text/javascript" src="#(ctx_path)/lib/DD_belatedPNG_0.0.8a-min.js" ></script>
	<script>DD_belatedPNG.fix('*');</script>
	<![endif]-->
	<title>按钮配置</title>
</head>
<body>
<input type="hidden" id="roleId" value="#(sysRole.id)">
<nav class="breadcrumb">
	<i class="Hui-iconfont">&#xe67f;</i> 首页 <span class="c-gray en">&gt;</span> 系统管理 <span class="c-gray en">&gt;</span> 按钮配置
	<span style="margin-left: 700px;">
				当前角色为：#(sysRole.name)
	</span>
	<a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新" ><i class="Hui-iconfont">&#xe68f;</i></a></nav>

<table class="table suitHeight">
	<tr>
		<td width="200" class="va-t"><ul id="treeDemo" class="ztree"></ul></td>
		<td class="va-t"><iframe ID="testIframe" Name="testIframe" FRAMEBORDER="0" SCROLLING="AUTO" width="100%" height="100%" SRC=""></iframe></td>
	</tr>
</table>
<!--_footer 作为公共模版分离出去-->
<script type="text/javascript" src="#(ctx_path)/lib/jquery/1.9.1/jquery.min.js"></script>
<script type="text/javascript" src="#(ctx_path)/lib/layer/2.4/layer.js"></script>
<script type="text/javascript" src="#(ctx_path)/static/h-ui/js/H-ui.min.js"></script>
<script type="text/javascript" src="#(ctx_path)/static/h-ui.admin/js/H-ui.admin.js"></script> <!--/_footer 作为公共模版分离出去-->

<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript" src="#(ctx_path)/lib/zTree/v3/js/jquery.ztree.all-3.5.min.js"></script>
<script type="text/javascript">
    var zNodes;
    /*
    [
            { "id":1, "pId":0, name:"一级分类"},//, open:true
            { "id":3, "pId":1, name:"二级分类"},
            { "id":12, pId:3, name:"三级分类"},
            { "id":13, pId:3, name:"三级分类"},
            { "id":14, pId:3, name:"三级分类"},
            { "id":15, pId:3, name:"三级分类"},
            { "id":16, pId:3, name:"三级分类"},
            { "id":2, pId:1, name:"二级分类 1-2"},
            { "id":17, pId:2, name:"三级分类 1-2-1"},
            { "id":18, pId:2, name:"三级分类 1-2-2"},
        ];
    */
    var code;

    function showCode(str) {
        if (!code) code = $("#code");
        code.empty();
        code.append("<li>"+str+"</li>");
    }

    $(document).ready(function(){
        var h = document.documentElement.clientHeight || document.body.clientHeight;
        $(".suitHeight").css("height",h*0.95+"px");
        loadAllMenu();
        var t = $("#treeDemo");
        t = $.fn.zTree.init(t, setting, zNodes);
        demoIframe = $("#testIframe");
        //demoIframe.on("load", loadReady);
        var zTree = $.fn.zTree.getZTreeObj("tree");
        //zTree.selectNode(zTree.getNodeByParam("id",'11'));
    });


    //加载菜单
    function loadAllMenu(){
        var param={"roleId":$("#roleId").val()};
        $.ajax({
            type: 'POST',
            url: '#(ctx_path)/admin/buttonList/findAllMenuByRoleNoDeal.html',
            data: param,
            async: false,
            dataType: 'json',
            success: function (data) {
                for (var i=0;i<data.length;i++){
                    if (data[i].id == 0){
                        data[i].open = true;
                        break;
                    }
                }
                zNodes = data;
            },
            error:function(data) {
                layer.msg('系统错误，请联系管理员！', {icon: 5,time:1500});
                console.log(data.msg);
            }
        });
    }
    var setting = {
        view: {
            dblClickExpand: false,
            showLine: false,
            selectedMulti: false
        },
        data: {
            simpleData: {
                enable:true,
                idKey: "id",
                pIdKey: "pid",
                rootPId: ""
            }
        },
        callback: {
            beforeClick: function(treeId, treeNode) {
                var zTree = $.fn.zTree.getZTreeObj("tree");
                if (treeNode.isParent) {
                    if (zTree == null){

                    } else {
                        zTree.expandNode(treeNode);
                    }
                    return false;
                } else {
                    demoIframe.attr("src", "#(ctx_path)/admin/roleAuth/showRoleAuthButton/"+treeNode.id+"-#(sysRole.id)");
                    return true;
                }
            }
        }
    };


</script>

</body>
</html>